﻿using System.Text;

namespace OpenCompiler.Scanning.Scanners
{
	public unsafe class NumericLiteralScanner : TokenScanner
	{
		private const string NumericLiteralCharacters = "0123456789.";
		private readonly char[] _numericLiteralCharacters;

		public NumericLiteralScanner()
		{
			this._numericLiteralCharacters = Encoding.Default.GetChars(Encoding.Default.GetBytes(NumericLiteralCharacters));			
		}

		public override bool IsToken(char* stringPointer, int remainingCharacters)
		{
			return TokenHelper.IsCharacter(stringPointer[0], this._numericLiteralCharacters);
		}

		public override object GetToken(ref char* stringPointer, int remainingCharacters)
		{
			return TokenHelper.GetToken(ref stringPointer, ref remainingCharacters, this._numericLiteralCharacters);
		}
	}
}
